disp "****Version: pred****"
*egg, generate eitc_unadj here
*egg, added 2 lines here may 22.  also added capture here for the parent version
local bo = "birth_order"
capture gen pred_eitc_unadj =.
capture gen pred_eitc_unadjnk =.

gen i_pred_eitcany = .
gen i_pred_noeitc5 = .

forvalues k=0/3 {
	disp "****Kid: `k'****"
	local k1 = "`k'="
	if `k'==3 local k1="3 <"


		replace pred_eitc_unadj = pred_agiz_unadj*(eitc_inrate`k'/100)  if pred_agiz_unadj<eitc_maxcstart`k' & `k1'=`bo'
		replace pred_eitc_unadj = eitc_maxc`k'  if inrange(pred_agiz_unadj,eitc_maxcstart`k',eitc_outstart`k')  &`k1'=`bo'
		replace pred_eitc_unadj = eitc_maxc`k'-(pred_agiz_unadj-eitc_outstart`k')*(eitc_outrate`k'/100)  if inrange(pred_agiz_unadj,eitc_outstart`k',eitc_outend`k')  &`k1'=`bo'
		replace pred_eitc_unadj = 0 if pred_agiz_unadj>eitc_outend`k' & `k1'=`bo'
		replace pred_eitc_unadj = 0 if year<=1975
		replace pred_eitc_unadj = . if pred_agiz_unadj==.

		replace pred_eitc_unadjnk = pred_agiz_unadj*(eitc_inrate`k'/100)  if pred_agiz_unadj<eitc_maxcstart`k' & `k1'=`bo'-1
		replace pred_eitc_unadjnk = eitc_maxc`k'  if inrange(pred_agiz_unadj,eitc_maxcstart`k',eitc_outstart`k')  &`k1'=`bo'-1
		replace pred_eitc_unadjnk = eitc_maxc`k'-(pred_agiz_unadj-eitc_outstart`k')*(eitc_outrate`k'/100)  if inrange(pred_agiz_unadj,eitc_outstart`k',eitc_outend`k')  &`k1'=`bo'-1
		replace pred_eitc_unadjnk = 0 if pred_agiz_unadj>eitc_outend`k' & `k1'=`bo'-1
		replace pred_eitc_unadjnk = 0 if year<=1975
		replace pred_eitc_unadjnk = . if pred_agiz_unadj==.

		capture gen pred_deitc_unadj = .
		capture gen pred_deitc = .
		capture gen pred_eitc = .


		replace pred_deitc_unadj = pred_eitc_unadj-pred_eitc_unadjnk

		replace pred_deitc = pred_deitc_unadj*(cpi_2015/cpi_jan)
		replace pred_deitc= 0 if year<=1975

		replace pred_eitc = pred_eitc_unadj*(cpi_2015/cpi_jan)



	replace i_pred_eitcany = (pred_agiz_unadj<eitc_outend`k') if `k1'=`bo'
	replace i_pred_eitcany = . if pred_agiz_unadj==.
	replace i_pred_eitcany = 0 if year<=1975

	replace i_pred_noeitc5 = (inrange(pred_agiz_unadj, 1.25*eitc_outend`k',2.25*eitc_outend`k')) if `k1'=`bo'
	replace i_pred_noeitc5 = . if pred_agiz_unadj==.

}
